import {defineStore} from "pinia";
import {ref} from "vue";

export const useOrderInfoStore=defineStore('orderInfo',()=>{
        const business=ref({
            businessId:0,
            businessName:"",
            deliveryPrice:0,
            businessImg:""
        })
        const foodList=ref([{
            foodId:0,
            foodName:"",
            foodExplain:"",
            foodImg:"",
            foodPrice:0,
            businessId:0,
            quantity:0
        }])

        function setBusiness(newBusiness){
            business.value=newBusiness
        }
        function removeBusiness(){
            business.value.businessId=0
            business.value.businessName=""
            business.value.deliveryPrice=0
        }
        function setFoodList(list){
            foodList.value=list
        }
        function removeFoodList(){
            foodList.value=[{
                foodId:0,
                foodName:"",
                foodExplain:"",
                foodImg:"",
                foodPrice:0,
                businessId:0,
                quantity:0
            }]
        }
        return{
            business,foodList,setBusiness,removeBusiness,setFoodList,removeFoodList
        }
    },
    {
        persist:true
    }
);